﻿"""
Jieun Oh

window.py -- Jieun's implementation of window functions for Music 422 HW3 #2

"""
import numpy as np
#import pylab



#------------------------------sine window-----------------------------#
def SineWindow(dataSampleArray):
     """returns a windowed copy of dataSampleArray using sine window (utilized in the main data path windowing)"""
     N = np.size(dataSampleArray)
     t = np.arange(N)
     w = np.sin(2*np.pi*t/(2*N-2))

     return w*dataSampleArray



#------------------------------hanning window----------------------------#

def HanningWindow(dataSampleArray):
     """returns a windowed copy of dataSampleARray using hanning window (utilized in the side chain FFT for the psychoacoustic model) """
     N = np.size(dataSampleArray)
     w = np.hanning(N)

     return w*dataSampleArray




# --------------------------Testing the window--------------------------------#

if __name__=="__main__":
     a = np.ones(100)
     sw = SineWindow(a)
     hw = HanningWindow(a)

     pylab.plot(sw,'r')
     pylab.plot(hw,'g')

     pylab.show()
